import CommonApi from './common'
import { uploadFileTimeout } from '@/config/settings'

// 日常养护 /日常养护计量 /合同管理
class ContractApi extends CommonApi {
    constructor() {
        super()
        this.scope = '/ms/contract'
    }

    // 导入模版下载地址
    static templatePath = '/ms/quantities/template/download'

    // 导入错误结果下载地址
    static importResultPath = '/ms/quantities/error/log/download'

    // 工程量清单和计日工导出地址
    static quantitiesAndDayExportPath = '/ms/quantities/export'

    records(data) {
        const path = this.resolvePath('/page/list')
        return this.post(path, data)
    }
    // 获取所有已经锁定的合同
    getListByLock(data) {
        const path = '/ms/daily/contract/list'
        return this.post(path, data)
    }
    // 获取合同养护范围
    getScopes(data) {
        const path = '/ms/daily/contract/socpes'
        return this.post(path, data)
    }
    // 获取不分页的合同列表，用于获取合同下拉框
    allList(data) {
        const path = this.resolvePath('/list')
        return this.post(path, data)
    }
    contractorList(data) {
        const path = this.resolvePath('/org/list')
        return this.post(path, data)
    }
    // 名称唯一性检查
    validNameUnique(data) {
        const path = this.resolvePath('/verification')
        return this.post(path, data)
    }
    // 清单子目编码唯一性检查
    validQuantitiesUnique(data) {
        const path = '/ms/quantities/verification'
        return this.post(path, data)
    }

    saveOrUpdate(data) {
        const path = this.resolvePath('/save')
        return this.post(path, data)
    }
    // 复制合同
    copySave(data) {
        const path = this.resolvePath('/copy')
        return this.post(path, data)
    }

    detail(data) {
        const path = this.resolvePath('/detailsById')
        return this.post(path, data)
    }
    delete(data) {
        const path = this.resolvePath('/delete/batch')
        return this.post(path, data)
    }
    lock(data) {
        const path = this.resolvePath('/lock')
        return this.post(path, data)
    }

    // 章次列表
    chapterList() {
        const path = '/ms/standard-bill-quantites/chapter/list'
        return this.post(path)
    }
    // 分类列表
    classifyList() {
        const path = '/ms/standard-bill-quantites/daywork-category/list'
        return this.post(path)
    }
    // 工程量清单列表
    quantitiesList(data) {
        const path = '/ms/quantities/page/list'
        return this.post(path, data)
    }
    // 工程量清单列表，用于添加子项搜索返回二位数组
    quantitiesListSearch(data) {
        const path = '/ms/quantities/search/list'
        return this.post(path, data)
    }
    // 单位列表
    unitList(data) {
        const path = '/ms/unit/list'
        return this.post(path, data)
    }

    // 子类新增
    childSaveOrUpdate(data) {
        const path = '/ms/quantities/save'
        return this.post(path, data)
    }

    // 查询当前合同下的章次
    chapterListById(data) {
        const path = '/ms/bill/chapter/list'
        return this.post(path, data)
    }

    // 当前合同新增章次
    chapterAdd(data) {
        const path = '/ms/bill/chapter/save/batch'
        return this.post(path, data)
    }
    // 删除章次
    chapterDelete(data) {
        const path = '/ms/bill/chapter/delete/batch'
        return this.post(path, data)
    }
    // 已删除清单
    delList(data) {
        const path = '/ms/quantities/del/list'
        return this.post(path, data)
    }
    // 导入
    import(form) {
        const headers = { 'content-type': 'multipart/form-data' }
        const path = '/ms/quantities/import'
        return this.post(path, form, {
            headers,
            timeout: uploadFileTimeout
        })
    }
    // 子项删除
    deleteChild(data) {
        const path = '/ms/quantities/delete/batch'
        return this.post(path, data)
    }
    // 获取计日工和工程量汇总清单
    statisticsist(data) {
        const path = '/ms/quantities/statistics'
        return this.post(path, data)
    }

    // 获取相关操作日志
    logsList(data) {
        const path = '/ms/logs/page/list'
        return this.post(path, data)
    }
    // 获取子项清单操作日志
    billLogsList(data) {
        const path = '/ms/bill/logs/page/list'
        return this.post(path, data)
    }
}

export default ContractApi
